<!doctype html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta http-equiv="content-style-type" content="text/css">
<link rel="stylesheet" type="text/css" href="../style.css">
<title>ReTrace Examples</title>
</head>
<body>

<script type="text/javascript" language="JavaScript">
<!--
if (window.self==window.top)
  document.write('<a target="_top" href="../index.html#retrace/examples.html" class="largebutton">DexGuard index</a>')
//-->
</script>
<noscript>
<a target="_top" href="../index.html#retrace/examples.html" class="largebutton">DexGuard index</a>
</noscript>

<h2>Examples</h2>

Some typical example uses:
<ol>
<li><a href="#with">Restoring a stack trace with line numbers</a></li>
<li><a href="#withverbose">Restoring a stack trace with line numbers
    (verbose)</a></li>
<li><a href="#without">Restoring a stack trace without line numbers</a></li>
</ol>

<h3><a name="with">Restoring a stack trace with line numbers</a></h3>

Assume for instance an application has been obfuscated using the following
extra options:
<pre>
-printmapping proguard.map

-renamesourcefileattribute DexGuard
-keepattributes SourceFile,LineNumberTable
</pre>
<p>

Now assume the processed application throws an exception, and we have saved the
stack trace in <code>proguard.trace</code>, shown below.

<pre>
Exception in thread "main" java.lang.Error: Random exception
        at pro.bY.a(DexGuard:576)
        at pro.bO.a(DexGuard:431)
        at pro.bj.a(DexGuard:145)
        at pro.bY.a(DexGuard:522)
        at pro.bj.a(DexGuard:129)
        at pro.bN.a(DexGuard:125)
        at pro.bY.a(DexGuard:251)
        at pro.bY.a(DexGuard:229)
        at pro.l.a(DexGuard:55)
        at pro.bo.b(DexGuard:405)
        at pro.ci.a(DexGuard:51)
        at pro.bo.a(DexGuard:356)
        at pro.be.a(DexGuard:109)
        at pro.bo.a(DexGuard:356)
        at pro.be.a(DexGuard:186)
        at pro.bg.a(DexGuard:369)
        at pro.bY.a(DexGuard:286)
        at pro.bh.a(DexGuard:55)
        at pro.bg.b(DexGuard:408)
        at pro.bY.a(DexGuard:190)
        at pro.bg.a(DexGuard:369)
        at pro.M.a(DexGuard:110)
        at pro.bY.a(DexGuard:449)
        at pro.M.a(DexGuard:99)
        at pro.bo.a(DexGuard:372)
        at pro.bY.a(DexGuard:649)
        at pro.bY.a(DexGuard:112)
        at pro.P.a(DexGuard:66)
        at pro.p.a(DexGuard:83)
        at pro.bU.a(DexGuard:69)
        at pro.bo.a(DexGuard:356)
        at pro.J.a(DexGuard:149)
        at pro.I.a(DexGuard:49)
        at pro.J.a(DexGuard:105)
        at pro.cf.c(DexGuard:370)
        at pro.cf.a(DexGuard:317)
        at pro.bc.a(DexGuard:55)
        at proguard.DexGuard.a(ProGuard:363)
        at proguard.DexGuard.c(ProGuard:187)
        at proguard.DexGuard.b(ProGuard:385)
        at proguard.DexGuard.main(ProGuard:429)
</pre>
<p>

We can then use the following command to recover the stack trace:
<pre>
<b>java -jar retrace.jar proguard.map proguard.trace</b>
</pre>
<p>

The output will look as follows:
<pre>
Exception in thread "main" java.lang.Error: Random exception
        at proguard.shrink.UsageMarker.visitInstruction(DexGuard:576)
        at proguard.classfile.instruction.GenericInstruction.accept(DexGuard:431)
        at proguard.classfile.CodeAttrInfo.instructionsAccept(DexGuard:145)
        at proguard.shrink.UsageMarker.visitCodeAttrInfo(DexGuard:522)
        at proguard.classfile.CodeAttrInfo.accept(DexGuard:129)
        at proguard.classfile.ProgramMemberInfo.attributesAccept(DexGuard:125)
        at proguard.shrink.UsageMarker.visitMemberInfo(DexGuard:251)
        at proguard.shrink.UsageMarker.visitProgramMethodInfo(DexGuard:229)
        at proguard.classfile.ProgramMethodInfo.accept(DexGuard:55)
        at proguard.classfile.ProgramClassFile.methodAccept(DexGuard:405)
        at proguard.classfile.visitor.NamedMethodVisitor.visitProgramClassFile(DexGuard:51)
        at proguard.classfile.ProgramClassFile.accept(DexGuard:356)
        at proguard.classfile.visitor.ClassFileUpDownTraveler.visitProgramClassFile(DexGuard:109)
        at proguard.classfile.ProgramClassFile.accept(DexGuard:356)
        at proguard.classfile.visitor.ClassFileUpDownTraveler.visitLibraryClassFile(DexGuard:186)
        at proguard.classfile.LibraryClassFile.accept(DexGuard:369)
        at proguard.shrink.UsageMarker.visitLibraryMethodInfo(DexGuard:286)
        at proguard.classfile.LibraryMethodInfo.accept(DexGuard:55)
        at proguard.classfile.LibraryClassFile.methodsAccept(DexGuard:408)
        at proguard.shrink.UsageMarker.visitLibraryClassFile(DexGuard:190)
        at proguard.classfile.LibraryClassFile.accept(DexGuard:369)
        at proguard.classfile.ClassCpInfo.referencedClassAccept(DexGuard:110)
        at proguard.shrink.UsageMarker.visitClassCpInfo(DexGuard:449)
        at proguard.classfile.ClassCpInfo.accept(DexGuard:99)
        at proguard.classfile.ProgramClassFile.constantPoolEntryAccept(DexGuard:372)
        at proguard.shrink.UsageMarker.markCpEntry(DexGuard:649)
        at proguard.shrink.UsageMarker.visitProgramClassFile(DexGuard:112)
        at proguard.classfile.visitor.VariableClassFileVisitor.visitProgramClassFile(DexGuard:66)
        at proguard.classfile.visitor.MultiClassFileVisitor.visitProgramClassFile(DexGuard:83)
        at proguard.classfile.visitor.FilteredClassFileVisitor.visitProgramClassFile(DexGuard:69)
        at proguard.classfile.ProgramClassFile.accept(DexGuard:356)
        at proguard.classfile.ClassPool.classFileAccept(DexGuard:149)
        at proguard.classfile.visitor.NamedClassFileVisitor.visitClassPool(DexGuard:49)
        at proguard.classfile.ClassPool.accept(DexGuard:105)
        at proguard.KeepCommand.executeShrinkingPhase(DexGuard:370)
        at proguard.KeepCommand.execute(DexGuard:317)
        at proguard.CompoundCommand.execute(DexGuard:55)
        at proguard.DexGuard.executeCommands(ProGuard:363)
        at proguard.DexGuard.shrink(ProGuard:187)
        at proguard.DexGuard.execute(ProGuard:385)
        at proguard.DexGuard.main(ProGuard:429)
</pre>

<h3><a name="withverbose">Restoring a stack trace with line numbers (verbose)</a></h3>

In the previous example, we could also use the verbose flag:
<pre>
<b>java -jar retrace.jar -verbose proguard.map proguard.trace</b>
</pre>
<p>

The output will then look as follows:
<pre>
Exception in thread "main" java.lang.Error: Random exception
        at proguard.shrink.UsageMarker.void visitInstruction(proguard.classfile.ClassFile,proguard.classfile.instruction.Instruction)(DexGuard:576)
        at proguard.classfile.instruction.GenericInstruction.void accept(proguard.classfile.ClassFile,proguard.classfile.instruction.InstructionVisitor)(DexGuard:431)
        at proguard.classfile.CodeAttrInfo.void instructionsAccept(proguard.classfile.ClassFile,proguard.classfile.instruction.InstructionVisitor)(DexGuard:145)
        at proguard.shrink.UsageMarker.void visitCodeAttrInfo(proguard.classfile.ClassFile,proguard.classfile.CodeAttrInfo)(DexGuard:522)
        at proguard.classfile.CodeAttrInfo.void accept(proguard.classfile.ClassFile,proguard.classfile.visitor.AttrInfoVisitor)(DexGuard:129)
        at proguard.classfile.ProgramMemberInfo.void attributesAccept(proguard.classfile.ProgramClassFile,proguard.classfile.visitor.AttrInfoVisitor)(DexGuard:125)
        at proguard.shrink.UsageMarker.void visitMemberInfo(proguard.classfile.ProgramClassFile,proguard.classfile.ProgramMemberInfo)(DexGuard:251)
        at proguard.shrink.UsageMarker.void visitProgramMethodInfo(proguard.classfile.ProgramClassFile,proguard.classfile.ProgramMethodInfo)(DexGuard:229)
        at proguard.classfile.ProgramMethodInfo.void accept(proguard.classfile.ProgramClassFile,proguard.classfile.visitor.MemberInfoVisitor)(DexGuard:55)
        at proguard.classfile.ProgramClassFile.void methodAccept(proguard.classfile.visitor.MemberInfoVisitor,java.lang.String,java.lang.String)(DexGuard:405)
        at proguard.classfile.visitor.NamedMethodVisitor.void visitProgramClassFile(proguard.classfile.ProgramClassFile)(DexGuard:51)
        at proguard.classfile.ProgramClassFile.void accept(proguard.classfile.visitor.ClassFileVisitor)(DexGuard:356)
        at proguard.classfile.visitor.ClassFileUpDownTraveler.void visitProgramClassFile(proguard.classfile.ProgramClassFile)(DexGuard:109)
        at proguard.classfile.ProgramClassFile.void accept(proguard.classfile.visitor.ClassFileVisitor)(DexGuard:356)
        at proguard.classfile.visitor.ClassFileUpDownTraveler.void visitLibraryClassFile(proguard.classfile.LibraryClassFile)(DexGuard:186)
        at proguard.classfile.LibraryClassFile.void accept(proguard.classfile.visitor.ClassFileVisitor)(DexGuard:369)
        at proguard.shrink.UsageMarker.void visitLibraryMethodInfo(proguard.classfile.LibraryClassFile,proguard.classfile.LibraryMethodInfo)(DexGuard:286)
        at proguard.classfile.LibraryMethodInfo.void accept(proguard.classfile.LibraryClassFile,proguard.classfile.visitor.MemberInfoVisitor)(DexGuard:55)
        at proguard.classfile.LibraryClassFile.void methodsAccept(proguard.classfile.visitor.MemberInfoVisitor)(DexGuard:408)
        at proguard.shrink.UsageMarker.void visitLibraryClassFile(proguard.classfile.LibraryClassFile)(DexGuard:190)
        at proguard.classfile.LibraryClassFile.void accept(proguard.classfile.visitor.ClassFileVisitor)(DexGuard:369)
        at proguard.classfile.ClassCpInfo.void referencedClassAccept(proguard.classfile.visitor.ClassFileVisitor)(DexGuard:110)
        at proguard.shrink.UsageMarker.void visitClassCpInfo(proguard.classfile.ClassFile,proguard.classfile.ClassCpInfo)(DexGuard:449)
        at proguard.classfile.ClassCpInfo.void accept(proguard.classfile.ClassFile,proguard.classfile.visitor.CpInfoVisitor)(DexGuard:99)
        at proguard.classfile.ProgramClassFile.void constantPoolEntryAccept(proguard.classfile.visitor.CpInfoVisitor,int)(DexGuard:372)
        at proguard.shrink.UsageMarker.void markCpEntry(proguard.classfile.ClassFile,int)(DexGuard:649)
        at proguard.shrink.UsageMarker.void visitProgramClassFile(proguard.classfile.ProgramClassFile)(DexGuard:112)
        at proguard.classfile.visitor.VariableClassFileVisitor.void visitProgramClassFile(proguard.classfile.ProgramClassFile)(DexGuard:66)
        at proguard.classfile.visitor.MultiClassFileVisitor.void visitProgramClassFile(proguard.classfile.ProgramClassFile)(DexGuard:83)
        at proguard.classfile.visitor.FilteredClassFileVisitor.void visitProgramClassFile(proguard.classfile.ProgramClassFile)(DexGuard:69)
        at proguard.classfile.ProgramClassFile.void accept(proguard.classfile.visitor.ClassFileVisitor)(DexGuard:356)
        at proguard.classfile.ClassPool.void classFileAccept(proguard.classfile.visitor.ClassFileVisitor,java.lang.String)(DexGuard:149)
        at proguard.classfile.visitor.NamedClassFileVisitor.void visitClassPool(proguard.classfile.ClassPool)(DexGuard:49)
        at proguard.classfile.ClassPool.void accept(proguard.classfile.visitor.ClassPoolVisitor)(DexGuard:105)
        at proguard.KeepCommand.void executeShrinkingPhase(proguard.classfile.ClassPool,proguard.classfile.ClassPool)(DexGuard:370)
        at proguard.KeepCommand.void execute(int,proguard.classfile.ClassPool,proguard.classfile.ClassPool)(DexGuard:317)
        at proguard.CompoundCommand.void execute(int,proguard.classfile.ClassPool,proguard.classfile.ClassPool)(DexGuard:55)
        at proguard.DexGuard.void executeCommands(int)(ProGuard:363)
        at proguard.DexGuard.void shrink()(ProGuard:187)
        at proguard.DexGuard.void execute(java.lang.String[])(ProGuard:385)
        at proguard.DexGuard.void main(java.lang.String[])(ProGuard:429)
</pre>


<h3><a name="without">Restoring a stack trace without line numbers</a></h3>

Assume for instance the application DexGuard has been obfuscated using the
following extra options, this time without preserving the line number tables:
<pre>
-printmapping proguard.map
</pre>
<p>

A stack trace <code>proguard.trace</code> will then lack line number
information:
<pre>
Exception in thread "main" java.lang.Error: Random exception
        at pro.bY.a(Unknown Source)
        at pro.bO.a(Unknown Source)
        at pro.bj.a(Unknown Source)
        at pro.bY.a(Unknown Source)
        at pro.bj.a(Unknown Source)
        at pro.bN.a(Unknown Source)
        at pro.bY.a(Unknown Source)
        at pro.bY.a(Unknown Source)
        at pro.l.a(Unknown Source)
        at pro.bo.b(Unknown Source)
        at pro.ci.a(Unknown Source)
        at pro.bo.a(Unknown Source)
        at pro.be.a(Unknown Source)
        at pro.bo.a(Unknown Source)
        at pro.be.a(Unknown Source)
        at pro.bg.a(Unknown Source)
        at pro.bY.a(Unknown Source)
        at pro.bh.a(Unknown Source)
        at pro.bg.b(Unknown Source)
        at pro.bY.a(Unknown Source)
        at pro.bg.a(Unknown Source)
        at pro.M.a(Unknown Source)
        at pro.bY.a(Unknown Source)
        at pro.M.a(Unknown Source)
        at pro.bo.a(Unknown Source)
        at pro.bY.a(Unknown Source)
        at pro.bY.a(Unknown Source)
        at pro.P.a(Unknown Source)
        at pro.p.a(Unknown Source)
        at pro.bU.a(Unknown Source)
        at pro.bo.a(Unknown Source)
        at pro.J.a(Unknown Source)
        at pro.I.a(Unknown Source)
        at pro.J.a(Unknown Source)
        at pro.cf.c(Unknown Source)
        at pro.cf.a(Unknown Source)
        at pro.bc.a(Unknown Source)
        at proguard.DexGuard.a(Unknown Source)
        at proguard.DexGuard.c(Unknown Source)
        at proguard.DexGuard.b(Unknown Source)
        at proguard.DexGuard.main(Unknown Source)
</pre>
<p>

We can still use the same command to recover the stack trace:
<pre>
<b>java -jar retrace.jar proguard.map proguard.trace</b>
</pre>
<p>

The output will now give a list of alternative original method names for each
ambiguous obfuscated method name:
<pre>
Exception in thread "main" java.lang.Error: Random exception
        at proguard.shrink.UsageMarker.visitProgramClassFile(Unknown Source)
                                       visitLibraryClassFile
                                       visitProgramFieldInfo
                                       visitProgramMethodInfo
                                       visitMemberInfo
                                       visitLibraryFieldInfo
                                       visitLibraryMethodInfo
                                       visitIntegerCpInfo
                                       visitLongCpInfo
                                       visitFloatCpInfo
                                       visitDoubleCpInfo
                                       visitStringCpInfo
                                       visitUtf8CpInfo
                                       visitFieldrefCpInfo
                                       visitInterfaceMethodrefCpInfo
                                       visitMethodrefCpInfo
                                       visitClassCpInfo
                                       visitNameAndTypeCpInfo
                                       visitUnknownAttrInfo
                                       visitInnerClassesAttrInfo
                                       visitConstantValueAttrInfo
                                       visitExceptionsAttrInfo
                                       visitCodeAttrInfo
                                       visitLineNumberTableAttrInfo
                                       visitLocalVariableTableAttrInfo
                                       visitSourceFileAttrInfo
                                       visitDeprecatedAttrInfo
                                       visitSyntheticAttrInfo
                                       visitInstruction
                                       visitCpInstruction
                                       visitExceptionInfo
                                       visitInnerClassesInfo
                                       visitLocalVariableInfo
                                       markCpEntry
                                       markAsUnused
                                       isUsed
        at proguard.classfile.instruction.GenericInstruction.create(Unknown Source)
                                                             isWide
                                                             getLength
                                                             accept
        at proguard.classfile.CodeAttrInfo.getAttribute(Unknown Source)
                                           getAttrInfoLength
                                           readInfo
                                           accept
                                           instructionsAccept
                                           exceptionsAccept
        [...]
        at proguard.KeepCommand.executeShrinkingPhase(Unknown Source)
                                access$100
        at proguard.KeepCommand.keepField(Unknown Source)
                                ensureMultiClassFileVisitorForMembers
                                execute
                                executeObfuscationPhase
                                access$002
                                access$000
                                access$102
                                access$108
        at proguard.CompoundCommand.addCommand(Unknown Source)
                                    execute
        at proguard.DexGuard.readCommands(Unknown Source)
                             obfuscate
                             executeCommands
        at proguard.DexGuard.shrink(Unknown Source)
        at proguard.DexGuard.check(Unknown Source)
                             execute
        at proguard.DexGuard.main(Unknown Source)
</pre>

<hr />
<address>
Copyright &copy; 2002-2014
<a target="other" href="http://www.saikoa.com/">Saikoa BVBA</a>.
</address>
</body>
</html>

